<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=<device-width>, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="app"></div>
</body>
<script src="https://unpkg.com/vue@next"></script>
<script>
    const { ref, reactive } = Vue;
    const app = Vue.createApp({
        template: `
        <h4 style="color:red">使用 Composition实现todoList </h4>
        <div>
        <input v-model="inputVal">
        <button @click="handelToSubmit(inputVal">提交</button>   
        </div>
        <div>
            <ul>
                <li v-for="(item,index) in todoList" :key="index">
                {{item}}
                 </li>
            
            </ul>
        </div>
        `,
        setup(props) {
            const inputVal = ref('');
            let todoList = reactive([]);
            function handelToSubmit() {
                todoList.push(inputVal.value);
                inputVal.value = '';
            }
            return { inputVal, todoList, handelToSubmit }
        }

    })
    app.mount("#app")
</script>

</html>